﻿using gt.webapi.core.Repositories;
using System;
using System.Web.Http;
using System.Web.Http.Controllers;

namespace gt.webapi.core.Filters.Authority
{
    public abstract class AuthorizeFilterBase : AuthorizeAttribute
    {
        protected IAuthorityRepository m_authorityRepository = null;
        public AuthorizeFilterBase(IAuthorityRepository authorityRepository)
        {
            this.m_authorityRepository = authorityRepository ?? throw new ArgumentNullException("authorityRepository");
        }
        protected abstract override bool IsAuthorized(HttpActionContext actionContext);

        protected abstract override void HandleUnauthorizedRequest(HttpActionContext actionContext);
    }
}
